#include<iostream>
#include<string>
#include<unistd.h>
#include<pthread.h>

const int num=5;

void *Wait(void *args)
{
    std::string name=static_cast<const char*>(args);
    while (true)
    {
        std::cout<<"I am "<<name<<std::endl;
        sleep(1);
    }
    
}



int main()
{
    pthread_t threads[num];
    for(int i=0;i<num;i++)
    {
        char* name=new char[1024];
        snprintf(name,1024,"thread-%d",i+1);
        pthread_create(threads+i,nullptr,Wait,(void*)name);
    }

    for(int i=0;i<num;i++)
    {
        pthread_join(threads[i],nullptr);
    }


}